Python current

您所在的位置:网站首页 python active函数 Python current

Python current

2023-05-27 04:34| 来源: 网络整理| 查看: 265

本文整理汇总了Python中flask.ext.login.current_user.is_active函数的典型用法代码示例。如果您正苦于以下问题:Python is_active函数的具体用法?Python is_active怎么用?Python is_active使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了is_active函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: new_thread def new_thread(): """ Used to create new threads for discussion. """ if requesthod == 'POST': form = ThreadForm(request.form) if form.validate(): thread = form.populated_object() if current_user.is_active() and len(form.display_name.data) == 0: thread.user = current_user #TODO Put Role dropdown box in Python form role_display_hash = request.form['role'] thread.role = Role.query.filter(Role.display_hash==role_display_hash).first() db.session.add(thread) db.session.commit() return redirect(url_for('thread', display_hash=thread.display_hash, title=thread.slug())) if requesthod == 'GET': form = ThreadForm() if current_user.is_active(): roles = current_user.roles else: roles = None return render_template('new_thread.html', form=form, roles=roles, action=url_for('new_thread'))开发者ID:ruipacheco,项目名称:fruitshow2,代码行数:27,代码来源:views.py 示例2: thread def thread(display_hash=None, title=None): """ Add comments to an existing thread. """ if display_hash is None: abort(404) thread = Thread.query.filter(Thread.display_hash==display_hash).first() if not thread: abort(404) if not current_user.is_active() and thread.user is not None and \ thread.role is not None and thread.role not in current_user.roles: abort(403) if requesthod == 'POST': form = PostForm(request.form) if form.validate(): post = form.populated_object() post.thread = thread thread.last_updated = post.date_created if current_user.is_active(): post.user = current_user post.display_name = None db.session.add(post) db.session.commit() anchor = 'p' + str(post.display_hash) return redirect(url_for('thread', display_hash=thread.display_hash, title=thread.slug(), _anchor=anchor)) if requesthod == 'GET': form = PostForm() return render_template('thread.html', thread=thread, form=form)开发者ID:ruipacheco,项目名称:fruitshow2,代码行数:34,代码来源:views.py 示例3: index def index(): if current_user and current_user.is_active() and current_user.active_member: # is an aproved member user = DB.User.query.get(current_user.id) return render_template('my_account/overview.html', user=user) elif current_user and current_user.is_active(): # is logged in but not aproved yet return render_template('my_account/waiting_aproval.html') else: # is not logged in return redirect(url_for_security('login'))开发者ID:Oddly,项目名称:MALMan,代码行数:11,代码来源:views_my_account.py 示例4: test_update_password2 def test_update_password2(self): # Ensure update password behaves correctly. with self.client: self.client.post( '/login', data=dict( email='[email protected]', password='student_user', ), follow_redirects=True ) response = self.client.post( '/password', data=dict( password='short', confirm='short' ), follow_redirects=True ) self.assertIn( b'Update Password', response.data ) self.assertIn( b'Field must be between 6 and 25 characters long.', response.data ) self.assertTrue(current_user.email == '[email protected]') self.assertTrue(current_user.is_authenticated()) self.assertTrue(current_user.is_active()) self.assertFalse(current_user.is_anonymous()) self.assertTrue(current_user.is_student()) self.assertFalse(current_user.is_teacher()) self.assertFalse(current_user.is_admin()) self.assertEqual(response.status_code, 200)开发者ID:ddparker,项目名称:lms,代码行数:35,代码来源:test_user.py 示例5: get_data def get_data(): event = request.json['event'] # print request.headers if event == 'random_user': # Exclude me, my like users, users that don't show and my subscriptions if current_user.is_authenticated() and current_user.is_active(): exclude_list = [current_user.login] exclude_list.extend(current_user.users_like) exclude_list.extend(current_user.following) fields = ['sid', 'login', 'birthday', 'description'] fields_from_base = {field: '$' + field for field in fields} all_users = mongo.db.users.aggregate([ {"$group": {"_id": fields_from_base}} ]) clear_users = [user[u'_id'] for user in all_users['result'] if user[u'_id'][u'login'] not in exclude_list] random_user = random.choice(clear_users) random_user['age'] = age(random_user['birthday']) return jsonify(result='OK', user=random_user) else: return jsonify(result='None', data="User is not authenticated", event=event, user=str(_get_user())) return jsonify(status="No response", event=event)开发者ID:gitex,项目名称:dating,代码行数:25,代码来源:for_requests.py 示例6: test_correct_login def test_correct_login(self): with self.client: response = self.client.post("/login", data=dict(username="admin", password="admin"), follow_redirects=True) self.assertIn(b"You were logged in", response.data) self.assertTrue(current_user.name == "admin") self.assertTrue(current_user.is_active())开发者ID:fcs23800,项目名称:flask-intro,代码行数:7,代码来源:test.py 示例7: test_logout def test_logout(self): with self.client: response = self.client.post( '/login', data=dict(username="admin", password="admin"), follow_redirects=True) response = self.client.get('/logout', follow_redirects=True) self.assertTrue(b'You were just logged out' in response.data) self.assertFalse(current_user.is_active())开发者ID:wilcoxky,项目名称:flask-intro,代码行数:7,代码来源:test.py 示例8: test_user_registration_error def test_user_registration_error(self): # Ensure registration behaves correctly. token = stripe.Token.create( card={ 'number': '4242424242424242', 'exp_month': '06', 'exp_year': str(datetime.datetime.today().year + 1), 'cvc': '123', } ) with self.client: response = self.client.post( '/register', data=dict( email="[email protected]", password="testing", confirm="testing", card_number="4242424242424242", cvc="123", expiration_month="01", expiration_year="2015", stripeToken=token.id, ), follow_redirects=True ) user = User.query.filter_by(email='[email protected]').first() self.assertEqual(user.email, '[email protected]') self.assertTrue(user.paid) self.assertIn('Thanks for paying!', response.data) self.assertTrue(current_user.email == "[email protected]") self.assertTrue(current_user.is_active()) self.assertEqual(response.status_code, 200)开发者ID:dbans02,项目名称:flask-paywall,代码行数:32,代码来源:test_user.py 示例9: test_logout def test_logout(self): """Test user can logout.""" with self.client: self.login() response = self.client.get('/users/logout', follow_redirects=True) self.assertIn(b'You were logged out', response.data) self.assertFalse(current_user.is_active())开发者ID:hammygoonan,项目名称:link-shortener,代码行数:7,代码来源:users.py 示例10: decorated_function def decorated_function(*args, **kwargs): s = get_state() if mainApp.config['REQUIRE_LOGIN_FOR_DYNAMIC'] and not s.icebox: if not current_user.is_authenticated() or not \ current_user.is_active(): return redirect(url_for('login.login_page', next=request.url)) return f(*args, **kwargs)开发者ID:criswell,项目名称:noink,代码行数:7,代码来源:utils.py 示例11: test_logout_behaves_correctly def test_logout_behaves_correctly(self): # Ensure logout behaves correctly, regarding the session with self.client: self.client.post("/login", data=dict(email="[email protected]", password="admin_user"), follow_redirects=True) response = self.client.get("/logout", follow_redirects=True) self.assertIn("You were logged out. Bye!", response.data) self.assertFalse(current_user.is_active())开发者ID:ar-qun,项目名称:Flask-Landing,代码行数:7,代码来源:test_user.py 示例12: test_logout def test_logout(self): with self.client: self.client.post("/login", data=dict(username="admin", password="admin"), follow_redirects=True) response = self.client.get("/logout", follow_redirects=True) self.assertIn(b"You were logged out", response.data) self.assertFalse(current_user.is_active())开发者ID:fcs23800,项目名称:flask-intro,代码行数:7,代码来源:test.py 示例13: test_sign_out def test_sign_out(client): sign_up(username='testuser', password='1234') with client: sign_in(username='testuser', password='1234') logout_user() assert not current_user.is_active() assert current_user.is_anonymous()开发者ID:euphoris,项目名称:webpat,代码行数:7,代码来源:test_account.py 示例14: test_can_login def test_can_login(self): """Test user can login.""" with self.client: response = self.login() self.assertEqual(response.status_code, 200) self.assertTrue(current_user.is_active()) self.assertTrue(current_user.email == self.email)开发者ID:hammygoonan,项目名称:FlaskTemplate,代码行数:7,代码来源:users.py 示例15: _social_authorized def _social_authorized(provider, data): if provider not in social.providers: abort(404) if data is None: flash('You denied the request to sign in.') return redirect(url_for('login')) token = data.get('access_token', data.get('oauth_token', '')) secret = data.get('oauth_token_secret', '') setattr(g, '%s_token' % provider, token) setattr(g, '%s_secret' % provider, secret) if current_user.is_active(): getattr(current_user, 'link_%s' % provider)(data) flash('%s has been linked with your account!' % provider) return redirect(url_for('my_apps')) user = getattr(User, 'from_%s' % provider)(data) if user: login_user(user) flash('You were signed in!') # FIXME: redirect to wherever the user was return redirect(url_for('home'))开发者ID:RainCT,项目名称:flask-template-with-social,代码行数:26,代码来源:controller_social.py

注:本文中的flask.ext.login.current_user.is_active函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3